import 'package:flutter/material.dart';

ListView listView = ListView(
    children: <Widget>[
      IconButton(onPressed: () {}, icon: const Icon(Icons.share_outlined)),
      const ListTile(leading: Icon(Icons.map),  title: Text('Map')),
      const ListTile(leading: Icon(Icons.message),  title: Text('Message')),
    ]
);

ListView horizontalList = ListView(
    scrollDirection: Axis.horizontal,
    itemExtent: 140, //item延展尺寸(宽度)
    children: <Widget>[
          Container(color: Colors.black),
          Container(color: Colors.red),
          Container(color: Colors.blue),
          Container(color: Colors.green),
          Container(color: Colors.yellow),
          Container(color: Colors.orange),
    ]
);

ListView listBuilder = ListView.builder(
    itemCount: 100, //元素个数
    itemExtent: 50.0, //列表项高度
    itemBuilder: (BuildContext context, int index) => ListTile(title: Text("title $index"), subtitle: Text("body $index"))
);

ListView listSeparated = ListView.separated(
    itemCount: 100,
    separatorBuilder: (BuildContext context, int index) => index %2 ==0? const Divider(color: Colors.green) : const Divider(color: Colors.red),//index为偶数，创建绿色分割线；index为奇数，则创建红色分割线
    itemBuilder: (BuildContext context, int index) => ListTile(title: Text("title $index"), subtitle: Text("body $index"))//创建子Widget
);